package com.example.kafka.constant;

import org.apache.kafka.common.TopicPartition;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * @application:
 * @author: LiYuhang
 * @Date: 2021/4/11 20:47
 * @version: 0.1
 * @Description :
 * @Modified By:
 */
public interface KafkaConstant {
    //自定义topic
    public static final String TOPIC_TEST = "test";

    //
    public static final String TOPIC_GROUP1 = "topic.group1";

    //
    public static final String TOPIC_GROUP2 = "topic.group2";

    //指定partion
    public static final TopicPartition[]  PARTITIONS=new TopicPartition[]{
           new TopicPartition(TOPIC_TEST, 0),  new TopicPartition(TOPIC_TEST ,1)
    };

    public static final Integer ONCE_SEND_SIZE=100;

    public static final String DESERIALIZER="org.apache.kafka.common.serialization.StringDeserializer";
    public static final String SERIALIZER="org.apache.kafka.common.serialization.StringSerializer";


    public static   String generatorUuid() {
        String uuid = UUID.randomUUID().toString();
        uuid = uuid.replace("-","");
        String id = uuid + "-" + new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
        return id.toUpperCase();
    }
}
